from selenium.webdriver.common.by import By

from Base.base_page import AppBasePage


class SearchPage(AppBasePage):
    def __init__(self):
        super().__init__()
        #主页搜索框
        self.search_zy = (By.XPATH,'//*[@resource-id="com.ss.android.article.news:id/h6l"]')
        #搜索框输入框
        self.search_text = (By.XPATH,'//*[@resource-id="com.ss.android.article.news:id/d0"]')
        #搜索按钮
        self.search_button = (By.XPATH,'//*[@text="搜索"]')
        #退出搜索结果界面
        self.search_exit = (By.XPATH,'//*[@content-desc="返回"]')
        #退出搜索界面
        self.search_exit_button = (By.XPATH,'//*[@content-desc="返回"]')

    def to_get_search_result(self,text):
        self.click_element(self.find_element(self.search_zy))
        self.input_text(self.find_element(self.search_text),text)
        self.click_element(self.find_element(self.search_button))
    def to_get_exit_search(self):
        self.click_element(self.find_element(self.search_exit))
        self.click_element(self.find_element(self.search_exit_button))